#include <iostream>
#include <cstring>

using namespace std;

const char* mystrchr(const char *str, const char c)
{
    char *p = (char *)str;
    while(*p)
    {
        if(*p == c) return p;
        p++;
    }
    
    return 0;
}

const char* mystrrchr(const char *str, const char c)
{
    char *p = (char *)str;
    char *pr = 0;
    while(*p)
    {
        if(*p == c) pr = p;
        p++;
    }
    
    return pr;
}

int main(void)
{
    char str[31] = "Hello,world!";
    char *ptr = nullptr;
    /* test mystrchr */
    ptr = (char *)mystrchr(str, 'l');
    /* test mystrrchr */
    // ptr = (char *)mystrrchr(str, 'l');

    cout << (void *)ptr << endl;
    return 0;
}
